-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New Func backend: First iteration #559
base: main
Are you sure you want to change the base?
New Func backend: First iteration #559
Conversation
+ Func syntax tree + Essential functionality Func formatter + A new `codegen` package that includes the updated backend + Hacks in the compilation pipeline that allow to use both backends which is needed for differential testing.
Needed for bottom-up AST generation; e.g. function definiton might be generated from the expression that calls it.
Needed to test the backend leveraging structural typing in TS
Both backends generated some extra garbage.
Still idk, why things went wrong with that identifier there, as identifiers elsewhere work just fine
And semantically accurate function arguments (just tensors), albeit at the cost of some expressiveness of FunC
A summary of our recent conversation with @anton-trunov:
Some goals we would like to achieve in the new backend later:
Thus, I suggest limiting the scope of this backend to the following:
After implementing this, I suggest to merge this PR and add more functionality to it iteratively, covering it with tests. |
How about adding the new experimental option for this. Like, {
"projects": [
{
"name": "some_prefix",
"path": "./contract.tact",
"output": "./contract_output",
"options": {
"experimental": {
"newFuncBackend": true
}
}
}
]
} P.S.: Whoops, a miss-click — didn't mean to close the PR, sorry! |
Closes #526
Closes #619 (FunC grammar & parser by @novusnota)
Main roadmap
Write AST/formatter, and utilities to generate and emit Func code.It should be rewritten entirely at this step, since everything is interconnected in the old backend, and there are no any unit tests checking any specific functionality of the generated code.
The previous backend is basically untested. It requires to write a number of Tact contracts and setup code coverage to ensure that all the implemented features of the new backend work in the same way as in the old one.
Sub-roadmap of @novusnota
The goal is to create a comprehensive FunC grammar and parsed using the Ohm parsing toolkit. Should cover FunC version 0.4.4:
#pragma ...
grammar.ohm
)semantics.addOperation
)#include ...
global ...
const ...
ton-blockchain/ton
monorepoCurrent progress
Support JSON dumps for debugging purposessrc/generators/writers/write*.ts
; similar code structure if possible)Expression
Statement
Function
Literal
Contract
Constant
WriteContext
)src/generators/resolveFunc.*.ts
)"used" identifiersWriteContext
. The existing structure based on.context
/.used
calls is too imperative and makes the source code unreadable. Thus, a better design should be developed.src/codegen/README.md
)main
incorporating upstream changes to the new backend:Write new unit tests if neededWrite unit tests for the codegen, since we don't have anyNotes
yarn build && NEW_CODEGEN=1 PRINT_FUNC=1 ./bin/tact --config <project.config.json>
. It will print the generated source in stdout. UnsetNEW_CODEGEN
to run the same with the old backend.yarn test src/codegen/codegen.spec.ts
FuncAst
prefix. When creating a separate packge, we could remove theFunc
part; and add it only to our project. This could be done creating a separate module that includesindex.ts
with public exports like:export { AstComment as FuncAstComment } from '@func-package-name';